﻿using BluetoothDemo.Internal;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;
using System.IO;
using System.Windows;

namespace BluetoothDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        static BluetoothClient? bluetoothClient;
        static bool isConnected;
        public MainWindow()
        {
            InitializeComponent();
            sdfsdfdsa();
        }

        private void sdfsdfdsa()
        {
            //var dispositivos1 = PrinterManage.FindListAsync().Result;
            BluetoothClient cli = new BluetoothClient();
            var deviceList = PrinterManage.FindPairedListAsync().Result;
            var device = deviceList[1];
            
            device.Refresh();
            if (!device.Connected)
            {
                cli.Connect(device.DeviceAddress, InTheHand.Net.Bluetooth.BluetoothService.SerialPort);
            }
            var name = deviceList[1].DeviceName;
            PrinterManage.ConnectAsync(name, printerType: PrinterType.i80mm).Wait();
        }
    }
}